package com.soft.javase.day08.linkedlist;

import java.util.LinkedList;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/28
 */
public class StackSimulation {
    public static void main(String[] args) {

        LinkedList<Person> stack = new LinkedList<>();

        // 压栈添加到栈顶
        stack.addFirst(new Person("张三", 25));
        stack.addFirst(new Person("李四", 30));
        stack.addFirst(new Person("王五", 35));

        System.out.println("压栈后栈内容: " + stack);

        // 弹栈从栈顶移除
        Person removepPerson = stack.removeFirst();
        System.out.println("弹栈元素: " + removepPerson);

        System.out.println("弹栈后栈内容: " + stack);

        // 查看栈顶元素
        Person peekPerson = stack.peekFirst();
        System.out.println("栈顶元素: " + peekPerson);

        System.out.println("栈当前内容: " + stack);
    }
}
